home *** CD-ROM | disk | FTP | other *** search
/ Ubisoft Digital Press Ki….S.A./North America (USA) / Ubisoft Digital Press Kit 99 U.S.A.-North America (USA).bin / Dcr / language2.cst / 00036_Script_Scroll Text Beh contact < prev    next >
Text File  |  1999-05-03  |  3KB  |  95 lines

  1.  
  2.  
  3. -- Scroll Text Behavior
  4. ---------------------------------------------------------------
  5. -- This behavior the text in response to messages from the 
  6. -- arrow buttons, track, or indicator.
  7. --
  8. -- You attach this behavior to a text sprite.
  9. --
  10. -- 10/22/97 David Benman
  11. ---------------------------------------------------------------
  12.  
  13.  
  14. -- pTextSprite - the behavior's sprite.
  15. -- pTextMember - member reference for the text member in the sprite.
  16. -- pTextLowerLimit - lower limit for the text scrolling.
  17. -- pTextRange - entire range the text scrolls.
  18. -- pLineSize - the amount the text scrolls when the
  19. -- user clicks a button once. Usually the line height.
  20. property  pTextSpritec, pTextMemberc, pTextLowerLImitc, pTextRangec, pLineSizec, pPageSizec, pTextOrigin
  21.  
  22.  
  23. -- This handler initializes several properties, sets the limits
  24. -- for the text scrolling, and scrolls the text to its beginning
  25. -- position.
  26. on beginSprite me
  27.   set pLineSizec to 13
  28.   set totalLines to 15
  29.   set pPageSizec to totalLines * pLineSizec
  30.   set pTextOrigin to 255
  31.   
  32.   set pTextSpritec to the spriteNum of me
  33.   set pTextMemberc to the member of sprite pTextSpritec
  34.   
  35.   set lastOffset to integer(0.5 * totalLines) * plineSizec
  36.   set textUpperLimit to the height of member pTextMemberc - lastOffset
  37.   set pTextLowerLimitc to 0
  38.   set pTextRangec to textUpperLimit - pTextLowerLimitc
  39.   
  40.   set the locV of sprite pTextSpritec to pTextOrigin
  41.   
  42. end
  43.  
  44.  
  45. -- This handler scrolls the text in response to messages from the
  46. -- arrow buttons, track,  or indicator.
  47. -- direction - either a symbol indicating the direction of scrolling
  48. -- or a proportion to indicate a specific position.
  49. -- scrollType - contains the symbol #page when scrolling should
  50. -- be by page.
  51. on scrollTextc me, directionc, scrollType
  52.   
  53.   -- Sets the scrollAmount either a line or page depending on
  54.   -- the value for scrollType.
  55.   case TRUE of
  56.     (voidP(scrollType)):
  57.       set scrollAmount to pLineSizec
  58.     (scrollType = #page):
  59.       set scrollAmount to pPageSizec
  60.   end case
  61.   
  62.   -- Determines the next scroll position for the text. Sets the
  63.   -- next position to plus or minus one line, one page, or a specific
  64.   -- position depending on the value of direction.
  65.   if symbolP(directionc) then
  66.     
  67.     case directionc of
  68.       #down: set scrollDirectionc to 1
  69.       #up: set scrollDirectionc to -1
  70.     end case
  71.     
  72.     set scrollVector to scrollAmount * scrollDirectionc
  73.     set currentPosition to pTextOrigin -the locV of sprite pTextSpritec
  74.     set nextPosition to currentPosition + scrollVector
  75.     
  76.     if nextPosition > pTextLowerLimitc + pTextRangec then
  77.       set nextPosition to pTextLowerLimitc + pTextRangec
  78.     else
  79.       if nextPosition < pTextLowerLimitc then
  80.         set nextPosition to pTextLowerLimitc
  81.       end if
  82.     end if
  83.     
  84.   else
  85.     set nextPosition to directionc * pTextRangec
  86.   end if
  87.   
  88.   -- Sets the text to the next position.
  89.  set the locV of sprite pTextSpritec to pTextOrigin - nextPosition
  90.   
  91.   -- Sends a message to position the indicator to match the text.
  92.   sendAllSprites(#positionIndicatorc, float(nextPosition)/pTextRangec)
  93.   
  94. end
  95.